<template>
  <el-card class="card-box">
    <el-table border :data="formData">
      <el-table-column
        prop="id"
        label="id"
      />
      <el-table-column
        prop="username"
        label="用户名"
      />
      <el-table-column
        prop="realname"
        label="真实姓名"
      />
      <el-table-column
        prop="balance"
        label="余额"
      />
      <el-table-column
        prop="integral"
        label="积分"
      />
    </el-table>
    <el-row type="flex" justify="center">
      <el-pagination
        layout="prev, pager, next"
        :page-size="limit"
        :total="total"
        :current-page="page"
        @current-change="pageChange"
      />
    </el-row>
  </el-card>
</template>

<script>
import { getBalanceList } from '../../api/balance'
import { issue } from '@/api/space'
export default {
  data() {
    return {
      formData: [{}],
      limit: 5,
      start: 0,
      showDialog: false,
      total: 0,
      agent: null,
      category: null,
      title_contains: null,
      parking_lot_list: [
        { 'id': null, 'name': '全部停车场' }
      ], // 停车场下拉列表
      parking: null,
      charging_pile: null,
      free: null,
      page: 1,
      parking_lot: null,
      searchData: []
    }
  },
  async created() {
    // this.getProperties()
    this.getTotal()
    // this.getAgent()
    // this.getCategory()
    // this.parkingLotList()
  },
  methods: {
    // 信息
    async getTotal() {
      const res = await getBalanceList({
        page: this.page,
        pageSize: this.limit
      })
      this.formData = res.data.data.records
      this.total = res.data.data.total
      console.log('category', this.formData)
      console.log('total', this.total)
    },
    async issueSpace(id) {
      const data = {
        id: id
      }
      await issue(data)
      this.$message({
        message: '结算成功',
        type: 'success'
      })
      this.getTotal()
      // console.log(id)
    },
    pageChange(page) {
      this.page = page
      this.getTotal()
    },
    async getProperties() {
      const res = await getPropertiesList({
        _limit: this.limit,
        _start: this.start,
        title_contains: this.title_contains,
        agent: this.agent,
        category: this.category
      })
      // console.log(res)
      this.formData = res.data
      this.getTotal()
      // console.log('total', this.total)
    }
  }
}
</script>

<style lang="scss" scoped>
.card-box{
  margin: 20px;
}
</style>
